package cn.zktr.Personnel.controllers.tantiantian;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties.Pageable;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.zktr.Personnel.model.pojos.PerPmsPot;
import cn.zktr.Personnel.model.pojos.PerSlyScsy;
import cn.zktr.Personnel.model.pojos.PerSlyTax;
import cn.zktr.Personnel.model.service.tantiantian.SlyScsyService;

@Controller
public class SocialSecurityController {
	/**
	 * 社保项目
	 */
	@Autowired
	private SlyScsyService scsySer;
	
	//社保项目
	@RequestMapping("ttt/social-security")
	public void SocialSecurity(){
		
	}
	//社保项目
	@RequestMapping("scsytable")
	@ResponseBody
	public Map<String,Object> scsytable(int page,int rows){
		Map<String,Object> map = new HashMap<>();
		Page<Object> pg = PageHelper.startPage(page, rows);
		JSONArray selectScsyAll =  scsySer.selectScsyAll2();
		//总记录
		map.put("total", pg.getTotal());
		//页内容
		map.put("rows", selectScsyAll);
		
		return map;
	}
	
	/**
	 * @param slyscsy 新增社保项目
	 */
	@RequestMapping("addSecurity")
	@ResponseBody
	public void addSecurity(PerSlyScsy slyscsy){
		scsySer.addScsy(slyscsy);
	}
	//根据id查询社保项目及纳税
	
	@RequestMapping("SelectScsy")
	@ResponseBody
	public JSONArray SelectScsy(Integer scsyid){
		JSONArray seleScsyId = scsySer.seleScsyId(scsyid);
		return seleScsyId;
	}
	//新增社保纳税。，给社保添加纳税
	
	@RequestMapping("addTax")
	@ResponseBody
	public void addTax(String scsyid,PerSlyTax tax){
		scsySer.AddTAx(tax);
		System.err.println("id"+scsyid);
		scsySer.upScsy(Integer.parseInt(scsyid));
	}
	//根据社保项目名称查询社保项目scsytable_name
	@RequestMapping("scsytable_name")
	@ResponseBody
	public JSONArray scsytable_name(String text){
		return scsySer.scsytable_name(text);
	}
	
}
